package mvp.com.register.view.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import mvp.com.register.R;
import mvp.com.register.presenter.SplashPresenter;
import mvp.com.register.view.ISplashView;

/**
 * Created by YoungerChen on 2016/9/14.
 */
public class SplashActivity extends Activity implements ISplashView {

    SplashPresenter splashPresenter = new SplashPresenter(this);
    private TextView tv_version;
    private ProgressBar pb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);

        initView();
        splashPresenter.splash();


    }

    private void initView() {
        tv_version = (TextView) findViewById(R.id.tv_version);
        pb = (ProgressBar) findViewById(R.id.pb);
    }

    @Override
    public void toMain() {
        startActivity(new Intent(this, MainActivity.class));
    }

    @Override
    public void showProgress() {
        pb.setProgress(1);
    }

    @Override
    public void showDialog(String msg) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(msg);
        builder.show();
    }

    @Override
    public void showToast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void finishAs() {
        this.finish();
    }
}
